<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/style.css">
		<style>
			html,body {
				background-color: #FFFFFF;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <h1 class="mui-title">设置</h1>
		  <button id='setting' class=" mui-pull-right mui-btn-link">设置</button>

		</header>
		<div class="mui-content">
			<ul class="mui-table-view">
		        <li class="mui-table-view-cell">
		            <a class="mui-navigate-right dark-big">意见反馈</a>
		        </li>
		        <li id="cache" class="mui-table-view-cell">
		            <a class="mui-navigate-right dark-big">清除缓存</a>
		        </li>
		        <li id="about" class="mui-table-view-cell">
		            <a class="mui-navigate-right dark-big">关于我们</a>
		        </li>
		    </ul>
		</div>
	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/app.js"></script>

	<script>
		mui.init({
			swipeBack:true //启用右滑关闭功能
		});
		(function($, doc) {
				$.init();
				var settings = app.getSettings();
				var account = doc.getElementById('account');
				//
				window.addEventListener('show', function() {
					var state = app.getState();
					account.innerText = state.account;
				}, false);
				$.plusReady(function() {
					var settingPage = $.preload({
						"id": 'setting',
						"url": '../setting.html'
					});
					//设置
					var settingButton = doc.getElementById('setting');
					//settingButton.style.display = settings.autoLogin ? 'block' : 'none';
					settingButton.addEventListener('tap', function(event) {
						$.openWindow({
							id: 'setting',
							show: {
								aniShow: 'pop-in'
							},
							styles: {
								popGesture: 'hide'
							},
							waiting: {
								autoShow: false
							}
						});
					});
					//--
					$.oldBack = mui.back;
					var backButtonPress = 0;
					$.back = function(event) {
						backButtonPress++;
						if (backButtonPress > 1) {
							plus.runtime.quit();
						} else {
							plus.nativeUI.toast('再按一次退出应用');
						}
						setTimeout(function() {
							backButtonPress = 0;
						}, 1000);
						return false;
					};
				});
			}(mui, document));
		//给about节点添加点击事件
		document.getElementById('about').addEventListener('tap',function(){
			//打开关于我们页面
			mui.openWindow({
				id  : 'about.html',
				url : 'about.html'
			});
		});
		
		mui.plusReady(function(){
			//添加cache节点点击事件，清除缓存
			document.getElementById('cache').addEventListener('tap',function(){
				plus.cache.clear(function(){
					mui.toast('清除缓存成功');
				});
			});
		});
	</script>
</html>